<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改导游信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">修改导游信息</div>
                <div class="layui-card-body">
                    <form class="layui-form" action="" lay-filter="component-form-group">

                        <!--<div class="layui-form-item">-->
                            <!--<label class="layui-form-label">申请人姓名</label>-->
                            <!--<div class="layui-input-block">-->
                                <!--<input type="text" name="name" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">-->
                            <!--</div>-->
                        <!--</div>-->

                        <!--<div class="layui-form-item">-->
                            <!--<label class="layui-form-label">身份证号</label>-->
                            <!--<div class="layui-input-block">-->
                                <!--<input type="text" name="cardid" placeholder="请输入" autocomplete="off" class="layui-input">-->
                            <!--</div>-->
                        <!--</div>-->
                        <div class="layui-form-item">
                            <label class="layui-form-label">手机号</label>
                            <div class="layui-input-block">
                                <input type="text" name="guide_tel" placeholder="请输入" autocomplete="off" class="layui-input" value="{$res['guide_tel']}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">银行卡号</label>
                            <div class="layui-input-block">
                                <input type="text" name="guide_card" placeholder="请输入" autocomplete="off" class="layui-input" value="{$res['guide_card']}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">开户行</label>
                            <div class="layui-input-block">
                                <input type="text" name="guide_open_bank" placeholder="请输入" autocomplete="off" class="layui-input" value="{$res['guide_open_bank']}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">持卡人姓名</label>
                            <div class="layui-input-block">
                                <input type="text" name="guide_card_name" placeholder="请输入" autocomplete="off" class="layui-input" value="{$res['guide_card_name']}">
                            </div>
                        </div>
                        <input type="hidden" value="{$guide_id}" name="guide_id">
                        <div class="layui-form-item layui-layout-admin">
                            <div class="layui-input-block">
                                <div class="layui-inline" style="left: 0;">
                                    <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="addsubmit">修改</button>
                                    <a class="layui-btn layui-btn-primary prex" data-type="prex">返回</a>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','set','upload'], function(){
        $ = layui.jquery;
        var  admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,form = layui.form
            ,upload=layui.upload;

        form.render(null,'component-form-group');

        //添加提交
        form.on('submit(addsubmit)', function(data){
            //正则手机号
            var myreg = /^1\d{10}$/;
            if(!myreg.test($('[name=guide_tel]').val())){
                layer.msg('请输入正确的手机格式');
                return false;
            }

            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });

            $.ajax({
                url: "{:url('Merchant/editGuide')}",
                type: 'post',
                dataType: 'json',
                data: {data:data.field},
                success: function(data){
                    if (data.code === 0) {
                        layer.msg('添加成功',{icon:1,time:2000},function(){
                            window.location.href = "{:url('Merchant/guide')}";
                        });
                    }else if(data.code === 2){
                        layer.close(loading);
                        layer.msg('修改失败',{icon:2,time:1000})
                    }else if(data.code === 1){
                        layer.close(loading);
                        layer.msg(data.message,{icon:2,time:1000})
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });


        var $ = layui.$, active = {
            prex:function(){
                layer.confirm('确认取消本次编辑并返回吗？',function(){
                    window.location.href="{:url('Merchant/guide')}";
                });
            }
        };

        $('.prex').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script>


</body>
</html>